﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ConfigServices
{
    public class LayeredConfigReader : IConfigReader
    {
        private readonly IEnumerable<IConfigService> services;

        public LayeredConfigReader(IEnumerable<IConfigService> services)
        {
            this.services = services;
        }
        public string? GetValue(string name) 
        {
            string value = null;

            foreach(var service in services)
            {
                var val = service.GetValue(name);
                if (val != null)
                    value = val;
            }
            return value;
        }
    }
}
